package gate

import (
	"fmt"
	"fruit/actor/iactor"
	"fruit/tools/proto/proto_out/base"
	"fruit/tools/proto/proto_out/gate"

	"google.golang.org/protobuf/proto"
)

type GateUser struct {
	*iactor.Actor
}

func CreateGateUser() *GateUser {
	gt := &GateUser{}
	return gt
}

func (my *GateUser) InitIActor(args ...interface{}) interface{} {
	str := args[0].([]byte)
	req_msg := &base.GateUserInitReq{}
	proto.Unmarshal(str, req_msg)
	fmt.Println("Gate User Index", req_msg.Index)
	return &base.GateUserInitResp{}
}

func (my *GateUser) DestoryActor() {
	// my.GetActor().DestoryActor()
	// my.Actor = nil
	fmt.Printf("销毁 %s %s\n", iactor.Uid(my), iactor.Name(my))
}

func (my *GateUser) RecvTcpData(msg []byte) proto.Message {
	req := &gate.RecvDataReq{}
	proto.Unmarshal(msg, req)
	fmt.Printf("gate user 收到消息 %s\n", req.Data)
	return nil
}
